package com.zx.oa.dao.admin;

import com.zx.oa.dao.BaseDao;
import com.zx.oa.entity.Admin;

import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.util.ArrayList;
import java.util.List;

public class AdminDaoIpml extends BaseDao implements AdminDao{

    Connection conn = null;
    PreparedStatement pstmt = null;
    ResultSet rs = null;

    @Override
    public boolean login(String name, String pwd) {
        Admin admin = null;
        conn = this.getConnection();
        String sql = "SELECT logincode,password FROM zteadmin WHERE logincode=? AND password=?";
        try {
            pstmt = conn.prepareStatement(sql);
            pstmt.setString(1, name);
            pstmt.setString(2, pwd);
            rs = pstmt.executeQuery();
            if (rs.next()) {
                return true;
            }
        } catch (SQLException throwables) {
            throwables.printStackTrace();
        } finally {
            this.closeAll(conn, pstmt, rs);
        }
            return false;
    }
}
